package binarySearch;

/**
 * @author understand
 * @description:
 * @create 2025/5/18 21:37
 */
public class SearchMatrix {
    public static void main(String[] args) {
        int[][] matrix = {{1,3,5,7},{10,11,16,20},{23,30,34,60}};
        System.out.println(searchMatrix(matrix, 3));
    }
    public static boolean searchMatrix(int[][] matrix, int target) {
        int m = 0,  n = matrix[0].length-1;
        while (m < matrix.length && n >= 0) {
            if (matrix[m][n] == target) {
                return true;
            } else if (matrix[m][n] > target) {
                n--;
            } else {
                m++;
            }
        }
        return false;
    }
}
